package com.chlitina.store.modules.cash.model;

import com.chlitina.store.common.utils.DataFormater;
import com.chlitina.store.modules.base.entity.StoreCardTemplateAll;
import com.chlitina.store.modules.base.entity.StoreCardTemplateDuration;
import com.chlitina.store.modules.base.entity.StoreCardTemplateProduct;
import com.chlitina.store.modules.base.entity.StoreCardTemplateTimes;
import com.chlitina.store.modules.cash.entity.StoreCardAll;
import com.chlitina.store.modules.cash.entity.StoreCardDuration;
import com.chlitina.store.modules.cash.entity.StoreCardProduct;
import com.chlitina.store.modules.cash.entity.StoreCardTimes;

public class NewCardItem {
	private String project;
	private float retailPrice;
	private int amount;
	private String discount;
	private float realPrice;
	private float total;
	private int index=0;

	public String getProject() {
		return project;
	}

	public void setProject(String project) {
		this.project = project;
	}

	public float getRetailPrice() {
		return retailPrice;
	}

	public void setRetailPrice(float retailPrice) {
		this.retailPrice = retailPrice;
	}

	public int getAmount() {
		return amount;
	}

	public void setAmount(int amount) {
		this.amount = amount;
	}

	public String getDiscount() {
		return discount;
	}

	public void setDiscount(String discount) {
		this.discount = discount;
	}

	public float getRealPrice() {
		return realPrice;
	}

	public void setRealPrice(float realPrice) {
		this.realPrice = realPrice;
	}

	public float getTotal() {
		return total;
	}

	public void setTotal(float total) {
		this.total = total;
	}

	public static NewCardItem create(CardCart cardCart) {
		Object card = cardCart.getCard();
		if(card instanceof StoreCardAll){
			return create(cardCart,(StoreCardAll)card);
		}
		if(card instanceof StoreCardTimes){
			return create(cardCart,(StoreCardTimes)card);
		}
		if(card instanceof StoreCardProduct){
			return create(cardCart,(StoreCardProduct)card);
		}
		if(card instanceof StoreCardDuration){
			return create(cardCart,(StoreCardDuration)card);
		}
		return null;
	}

	
	public static NewCardItem create(CardCart cardCart,StoreCardAll storeCardAll) {
		NewCardItem item=new NewCardItem();
		item.setAmount(1);
		StoreCardTemplateAll template = storeCardAll.getTemplate();
		float real_cost = cardCart.getReal_cost();
		float retail_price = storeCardAll.getTemplate().getRetail_price();
		float dis=(real_cost/retail_price);
		item.setDiscount(DataFormater.format(dis));
		item.setRealPrice(real_cost);
		item.setRetailPrice(retail_price);
		item.setTotal(real_cost);
		item.setProject("新开卡：【"+template.getName()+"】");
		return item;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public static NewCardItem create(CardCart cardCart, StoreCardTimes card) {
		NewCardItem item=new NewCardItem();
		item.setAmount(1);
		StoreCardTemplateTimes template = card.getTemplate();
		float real_cost = cardCart.getReal_cost();
		float retail_price = template.getRetail_price();
		float dis=(real_cost/retail_price);
		item.setDiscount(DataFormater.format(dis));
		item.setRealPrice(real_cost);
		item.setRetailPrice(retail_price);
		item.setTotal(real_cost);
		item.setProject("新开卡：【"+template.getName()+"】");
		return item;
	}



	public static NewCardItem create(CardCart cardCart,StoreCardProduct card) {
		NewCardItem item=new NewCardItem();
		item.setAmount(1);
		StoreCardTemplateProduct template = card.getTemplate();
		float real_cost = cardCart.getReal_cost();
		float retail_price = template.getRetail_price();
		float dis=(real_cost/retail_price);
	
		item.setDiscount(DataFormater.format(dis));
		item.setRealPrice(real_cost);
		item.setRetailPrice(retail_price);
		item.setTotal(real_cost);
		item.setProject("新开卡：【"+template.getName()+"】");
		return item;
	}

	public static NewCardItem create(CardCart cardCart,StoreCardDuration card) {
		NewCardItem item=new NewCardItem();
		item.setAmount(1);
		StoreCardTemplateDuration template = card.getTemplate();
		float real_cost = cardCart.getReal_cost();
		float retail_price =template.getRetail_price();
		float dis=(real_cost/retail_price);
		item.setDiscount(DataFormater.format(dis));
		item.setRealPrice(real_cost);
		item.setRetailPrice(retail_price);
		item.setTotal(real_cost);
		item.setProject("新开卡：【"+template.getName()+"】");
		return item;
	}

}
